package com.quyunshuo.module.home.activity.details

import android.util.Log
import com.quyunshuo.androidbaseframemvvm.base.mvvm.m.BaseRepository
import com.quyunshuo.androidbaseframemvvm.network.bean.ArticleList
import com.quyunshuo.androidbaseframemvvm.network.bean.ArticleListRes2
import com.quyunshuo.androidbaseframemvvm.network.HomeApiService
import com.quyunshuo.androidbaseframemvvm.network.bean.BaseResponse
import javax.inject.Inject

/**
 * 首页M层
 *
 * @author Qu Yunshuo
 * @since 5/25/21 5:42 PM
 */
class DetailsRepository @Inject constructor() : BaseRepository() {

    @Inject
    lateinit var mApi: HomeApiService

    /**
     * 模拟获取数据
     */
    fun getData() = request<BaseResponse<ArticleListRes2>> {
        var response = mApi.listArticle(0)
        Log.d("test", "getData test: $response")
        emit(response)
    }

    fun doSearch(page: Int, keyWord: String)= request<BaseResponse<ArticleList>> {
        val searchResult = mApi.searchResult(page, keyWord)
        emit(searchResult)
    }
}